//
// Created by yangy on 2018/6/28.
//

#ifndef SUPERAUDIOPLAYER_WIPLAYER_H
#define SUPERAUDIOPLAYER_WIPLAYER_H

#include "WIAudio.h"
#include "JavaCallBack.h"
#include "include/ffmpeg.h"
#include <pthread.h>
#include "androidLog.h"
#include "WIVideo.h"

class WIPlayer {
public:
    //音频解码所需属性封装
    WIAudio *audio = NULL;
    WIVideo *video = NULL;
    //初始化回调java方法封装
    JavaCallBack * listener;
    //播放URL
    const char * url = NULL;
    //封装上下文
    AVFormatContext * av_format_ctx = NULL;
    //解码线程标识
    pthread_t decodeThread;
    //播放状态
    WIPlayState * playState;
    pthread_mutex_t playMutex;
    pthread_mutex_t seek_mutex;
    bool exit = false;
    int duration;
public:
    WIPlayer(WIPlayState * playState,const char * url,JavaCallBack * listener);
    ~WIPlayer();
    void prepare();
    void audioDecodeThread();
    void start();
    void release();
    void seek(int64_t secds);
    void setVolume(int level);
    void setMute(int mute);
    void setpitch(double pitch);
    void settempo(double tempo);
    int getSampleRate();
    void startRecord(bool start);
    void av_codec_init(AVCodecParameters *avCodecParameters,AVCodecContext **pAVCodecContext);
};


#endif //SUPERAUDIOPLAYER_WIPLAYER_H
